package com.qdlc.p2p.biz.tpp.model;

import java.io.IOException;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.qdlc.p2p.common.constant.SinaConstant;
import com.qdlc.p2p.common.util.DateUtil;
import com.qdlc.p2p.dal.common.SystemConfigHelper;
import com.qdlc.p2p.dal.common.SystemConfigHelper.Nid;

/**
 * 新浪提现
 * 
 * @author ylx
 * @version 2.0
 * @date 2015年8月11日 下午6:00:51
 */
public class SinaWithdraw extends SinaModel {
	/**
	 * 接口名称 : 开户
	 * 类型（长度）：String(64)
	 */
	private String service = "create_hosting_withdraw";
	
	/**
	 * 交易订单号：商户网站交易订单号，商户内部保证唯一
	 */
	private String out_trade_no;
	
	/**
	 * 摘要：提现内容摘要
	 */
	private String summary;
	
	/**
	 * 账户类型：账户类型（基本户、存钱罐）
	 */
	private String account_type;
	
	/**
	 * 金额：单位为：RMB Yuan。精确到小数点后两位。
	 */
	private String amount;
	
	/**
	 * 用户手续费：用户承担的手续费金额
	 */
	private String user_fee;
	
	/**
	 * 银行卡ID：用户绑定银行卡ID，即绑定银行卡返回的ID，如果走收银台可为空
	 */
	private String card_id;
	
	/**
	 * 提现状态
	 */
	private String withdraw_status;
	
	/**
	 * 待签名字符数组
	 */
	private String[] signParamNames=new String[]{"version","service","request_time","partner_id","_input_charset","identity_id","identity_type",
			"out_trade_no","account_type","amount","card_id","user_fee","notify_url"};
	
	/**
	 * 提交字符数组
	 */
	private String[] subParamNames=new String[]{"version","service","request_time","partner_id","_input_charset","sign","sign_type","identity_id","identity_type",
			"out_trade_no","account_type","amount","card_id","user_fee","notify_url"};
	
	/**
	 * 商户网站唯一订单号或者交易原始凭证号
	 */
	private String outer_trade_no;
	
	/**
	 * 内部交易凭证号
	 */
	private String inner_trade_no;
	
	/**
	 * 提现金额
	 */
	private String withdraw_amount;

	
	public SinaWithdraw() {
		super();
	}
	
	public SinaWithdraw(String out_trade_no, String account_type,
			String amount, String user_fee, String identity_id, String card_id) {
		super();
		this.out_trade_no = out_trade_no;
		this.account_type = account_type;
		this.amount = amount;
		this.user_fee = user_fee;
		this.setIdentity_type("UID");
		this.setIdentity_id(identity_id);
		this.setEncode(SinaConstant.ENCODE_TRUE);
		this.setRequest_time(DateUtil.dateStr3(DateUtil.getNow()));
		// 新浪回调地址
		
		this.setNotify_url(SystemConfigHelper.getValue(Nid.WEB_URL)+"/tpp/tppSinaAction/tppCashNotice.html");

		this.card_id = card_id;
		this.setUrl_type(SinaConstant.URL_TYPE_CASH);
	}



	@Override
	public SinaModel response(String res) throws IOException {
		try {
			JSONObject json = JSON.parseObject(res);
			outer_trade_no = json.getString("outer_trade_no");
			inner_trade_no = json.getString("inner_trade_no");
			withdraw_status = json.getString("withdraw_status");
			withdraw_amount = json.getString("withdraw_amount");
			card_id = json.getString("card_id");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	
	/**
	 * 获取服务名称
	 */
	public String getService() {
		return service;
	}

	/**
	 * 设置服务名称
	 */
	public void setService(String service) {
		this.service = service;
	}

	/**
	 * 获取交易订单号：商户网站交易订单号，商户内部保证唯一
	 * 
	 * @return
	 */
	public String getOut_trade_no() {
		return out_trade_no;
	}
	
	/**
	 * 设置交易订单号：商户网站交易订单号，商户内部保证唯一
	 * 
	 * @param out_trade_no
	 */
	public void setOut_trade_no(String out_trade_no) {
		this.out_trade_no = out_trade_no;
	}

	/**
	 * 获取摘要：提现内容摘要
	 * 
	 * @return
	 */
	public String getSummary() {
		return summary;
	}

	/**
	 * 设置摘要：提现内容摘要
	 * 
	 * @param summary
	 */
	public void setSummary(String summary) {
		this.summary = summary;
	}

	/**
	 * 获取账户类型：账户类型（基本户、存钱罐）
	 * 
	 * @return
	 */
	public String getAccount_type() {
		return account_type;
	}

	/**
	 * 设置账户类型：账户类型（基本户、存钱罐）
	 * 
	 * @param account_type
	 */
	public void setAccount_type(String account_type) {
		this.account_type = account_type;
	}

	/**
	 * 获取金额：单位为：RMB Yuan。精确到小数点后两位。
	 * 
	 * @return
	 */
	public String getAmount() {
		return amount;
	}

	/**
	 * 设置金额：单位为：RMB Yuan。精确到小数点后两位。
	 * 
	 * @param amount
	 */
	public void setAmount(String amount) {
		this.amount = amount;
	}

	/**
	 * 获取用户手续费：用户承担的手续费金额
	 * 
	 * @return
	 */
	public String getUser_fee() {
		return user_fee;
	}

	/**
	 * 设置用户手续费：用户承担的手续费金额
	 * 
	 * @param user_fee
	 */
	public void setUser_fee(String user_fee) {
		this.user_fee = user_fee;
	}

	/**
	 * 获取银行卡ID：用户绑定银行卡ID，即绑定银行卡返回的ID，如果走收银台可为空
	 * 
	 * @return
	 */
	public String getCard_id() {
		return card_id;
	}

	/**
	 * 设置银行卡ID：用户绑定银行卡ID，即绑定银行卡返回的ID，如果走收银台可为空
	 * 
	 * @param card_id
	 */
	public void setCard_id(String card_id) {
		this.card_id = card_id;
	}
	
	/**
	 * 获取提现状态
	 * @return
	 */
	public String getWithdraw_status() {
		return withdraw_status;
	}
	
	/**
	 * 设置提现状态
	 * @param withdraw_status
	 */
	public void setWithdraw_status(String withdraw_status) {
		this.withdraw_status = withdraw_status;
	}

	/**
	 * 获取签名参数数组
	 */
	public String[] getSignParamNames() {
		return signParamNames;
	}

	/**
	 * 设置签名参数数组
	 */
	public void setSignParamNames(String[] signParamNames) {
		this.signParamNames = signParamNames;
	}

	/**
	 * 获取提交参数数组
	 */
	public String[] getSubParamNames() {
		return subParamNames;
	}

	/**
	 * 设置提交参数数组
	 */
	public void setSubParamNames(String[] subParamNames) {
		this.subParamNames = subParamNames;
	}
	/**
	 * 获取商户网站唯一订单号或者交易原始凭证号
	 * 
	 * @return
	 */
	public String getOuter_trade_no() {
		return outer_trade_no;
	}

	/**
	 * 设置商户网站唯一订单号或者交易原始凭证号
	 * 
	 * @param outer_trade_no
	 */
	public void setOuter_trade_no(String outer_trade_no) {
		this.outer_trade_no = outer_trade_no;
	}

	/**
	 * 获取内部交易凭证号
	 * 
	 * @return
	 */
	public String getInner_trade_no() {
		return inner_trade_no;
	}

	/**
	 * 设置内部交易凭证号
	 * 
	 * @param inner_trade_no
	 */
	public void setInner_trade_no(String inner_trade_no) {
		this.inner_trade_no = inner_trade_no;
	}

	/**
	 * 获取提现金额
	 * 
	 * @return
	 */
	public String getWithdraw_amount() {
		return withdraw_amount;
	}

	/**
	 * 设置提现金额
	 * 
	 * @param withdraw_amount
	 */
	public void setWithdraw_amount(String withdraw_amount) {
		this.withdraw_amount = withdraw_amount;
	}
}
